package guarded.suspension;

import java.util.concurrent.Callable;

/**
 * Created by Administrator on 2017/3/16.
 */
public interface Blocker {

    /**
     * 在保护条件成立时执行目标动作，否则阻塞当前线程，直到保护条件成立
     * @param guardedAction</V> 带保护条件的目标动作
     * @param <V>
     * @return
     * @throws Exception
     */
    <V> V callWithGuard(GuardedAction<V> guardedAction) throws Exception;



    void signalAfter(Callable<Boolean> stateOperation) throws Exception;


    void signal() throws  InterruptedException;


    void broadcastAfter(Callable<Boolean> stateOperation) throws Exception;


}
